<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增合同')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-contract-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">合同编号：<i class="fa fa-asterisk text-danger"></i></label>
                <div class="col-sm-8">
                    <input name="contractNo" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合同名称：<i class="fa fa-asterisk text-danger"></i></label>
                <div class="col-sm-8">
                    <input name="contractName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合同年度：<i class="fa fa-asterisk text-danger"></i></label>
                <div class="col-sm-8">
                    <input name="contractYear" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合同金额：<i class="fa fa-asterisk text-danger"></i></label>
                <div class="col-sm-8">
                    <input name="amount" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">客户名称：</label>
                <div class="col-sm-8">
                    <input name="customer" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合同类型：</label>
                <div class="col-sm-8">
                    <select name="contractType" class="form-control"th:with="type=${@dict.getType('con_contract_type')}">
                        <option value="">所有</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">大区：</label>
                <div class="col-sm-8">
                    <input name="region" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">省份：</label>
                <div class="col-sm-8">
                    <input name="province" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合同开票金额：</label>
                <div class="col-sm-8">
                    <input name="invoicedAmount" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合同开票比例：</label>
                <div class="col-sm-8">
                    <input name="invoicedRatio" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合同总到款额：</label>
                <div class="col-sm-8">
                    <input name="receivedAmount" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">总到款比例：</label>
                <div class="col-sm-8">
                    <input name="receivedRatio" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">进度应收金额：</label>
                <div class="col-sm-8">
                    <input name="progressReceivableAmount" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">进度应收比例：</label>
                <div class="col-sm-8">
                    <input name="progressReceivableRatio" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">进度应收里程碑：</label>
                <div class="col-sm-8">
                    <input name="progressReceivableName" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">所属项目：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="projectIds" type="hidden" id="projectIds"/>
                        <input name="projectName" onclick="selectProjectList()" id="projectName" type="text" placeholder="请选择关联项目" class="form-control" required autocomplete="off">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "project/contract"
        $("#form-contract-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-contract-add').serialize());
            }
        }

        /**
         * 选择项目列表
         */
        function selectProjectList(){
            var projectIds = $("#projectIds").val();
            var url = ctx + "project/project/selectProjectList/" + projectIds;
            var options = {
                title: '选择项目',
                width: "600",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            // var tree = layero.find("iframe")[0].contentWindow.$._tree;
            // if ($.tree.notAllowParents(tree)) {
            //     var body = layer.getChildFrame('body', index);
            //     $("#deptId").val(body.find('#treeId').val());
            //     $("#deptName").val(body.find('#treeName').val());
            //     layer.close(index);
            // }
        }
    </script>
</body>
</html>